<?php
class TypeArticle {

	private $idType;

	public function __construct($id){
		$this->idType=$id;

	}


	public function getEntrepotSortie($date){
		$sql = "SELECT Count(*) as stock, E.nomSite
				FROM Entrepot E, SortieStock SS, Article A
				WHERE E.idSite = SS.entrepotIS
				AND A.numSerie = SS.articleNS
				AND A.typeArticle = '$this->idType'
				AND SS.dateSortie = '$date'";

		$req = mysql_query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.mysql_error());
		 
		$tab = array();
		$i = 0;
		while($row=mysql_fetch_array($req)){
			$tab[$i]= $row;
			$i++;
		}
		 
		return  $tab;
	}

	public function getEntrepotEntree($date){
		$sql = "SELECT Count(*) as stock, E.nomSite
				FROM Entrepot E, EntreeStock ES, Article A
				WHERE E.idSite = ES.entrepotIS
				AND A.numSerie = ES.articleNS
				AND A.typeArticle = '$this->idType'
				AND ES.dateEntree = '$date'";

		$req = mysql_query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.mysql_error());
		 
		$tab = array();
		$i = 0;
		while($row=mysql_fetch_array($req)){
			$tab[$i]= $row;
			$i++;
		}
		 
		return  $tab;
	}

}
?>

